package com.ltu.biz;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.ltu.domain.mp_entity.UserEntity;
import com.ltu.enums.UserMessageEnums;
import com.ltu.enums.UserMessageEnums.MessageDict;
import com.ltu.service.impl.VerifySmsCodeServiceImpl;

import cn.binarywang.wx.miniapp.api.WxMaMsgService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage.MsgData;
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
import cn.hutool.core.date.DateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;

@Slf4j
@Service
//@Transactional(rollbackFor = Exception.class)
@RequiredArgsConstructor(onConstructor = @__(@Autowired))  
public class UserMessageBiz {  
	private final WxMaService wxMaService;
	public  static WxMaMsgService wxMaMsgService;
	private static String page ="pages/pendingbills/pendingbills";
	
	@PostConstruct
	public void initialObj() {
		wxMaMsgService = wxMaService.getMsgService(); 
	}
	
	public  void  sendMsgData(String openId,String templateId,List<MsgData> msgList) {
		WxMaSubscribeMessage  wxMsg = new WxMaSubscribeMessage(openId,templateId, page ,msgList,WxMaConstants.MiniProgramState.DEVELOPER,WxMaConstants.MiniProgramLang.ZH_CN);
		try {
			wxMaMsgService.sendSubscribeMsg(wxMsg);
		} catch (WxErrorException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	 
	

}
